package cn.richx.pushmessage.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

// 用户权限关联表
@Entity
@Table(name = "kf_user_permission")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class UserPermission implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // 用户
    @NotNull
    @ManyToOne(fetch= FetchType.EAGER)
    @JsonBackReference
    @JoinColumn(name="user_id")
    private User user;

    // 权限编码
    @NotNull
    @ManyToOne(fetch= FetchType.EAGER)
    @JsonBackReference
    @JoinColumn(name="permission_code")
    private Permission permission;


    // 待操作部门或者班级ID
    @Size(max = 20)
    @Column(name = "opt_type_id",length = 20)
    private Long optTypeId;

    // 待操作类型
    // class 表示班级
    // dept 表示部门
    @Size(max = 50)
    @Column(name = "opt_type",length = 50)
    private String optType;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Permission getPermission() {
        return permission;
    }

    public void setPermission(Permission permission) {
        this.permission = permission;
    }

    public Long getOptTypeId() {
        return optTypeId;
    }

    public void setOptTypeId(Long optTypeId) {
        this.optTypeId = optTypeId;
    }

    public String getOptType() {
        return optType;
    }

    public void setOptType(String optType) {
        this.optType = optType;
    }


}
